# 导入:
from sqlalchemy import Column, String, create_engine, BIGINT, Integer
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from domain.domain import Catalog
from dao.CatalogDAO import CatalogDAO
from helper.ConnectionHelper import ConnectionHelper


# mysqlconnector
session=ConnectionHelper.GetSession()

catalogDao = CatalogDAO()
catalog = catalogDao.getById(session, 1)
catalog.name="植物2"
catalogDao.update(session,catalog)
newCatalog=Catalog(name="testName",parent_id=1,full_name="test",level=1,level_name="test",eng_name="test")
catalogDao1=catalogDao.add(session,newCatalog)
#catalogDao.update(session,catalog)


# 创建Query查询，filter是where条件，最后调用one()返回唯一行，如果调用all()则返回所有行:

# 打印类型和对象的name属性:
print('type:', type(catalog))
print('name:', catalog.name)
# 关闭Session:
session.close()
